<template>
  <footer class="footer">
    <span class="todo-count"
      >总计：<strong>{{ list.length }}</strong></span
    >
    <ul class="filters">
      <li>
        <a
          @click="changeState('all')"
          :class="{ selected: state === 'all' }"
          href="javascript:;"
          >全部</a
        >
      </li>
      <li>
        <a
          @click="changeState('unfinish')"
          :class="{ selected: state === 'unfinish' }"
          href="javascript:;"
          >未完成</a
        >
      </li>
      <li>
        <a
          @click="changeState('finished')"
          :class="{ selected: state === 'finished' }"
          href="javascript:;"
          >已完成</a
        >
      </li>
    </ul>
    <button class="clear-completed" @click="clearFinished">清除已完成</button>
  </footer>
</template>

<script>
export default {
  props: {
    list: {
      type: Array,
      default: () => []
    },
    state: {
      type: String,
      default: ''
    }
  },
  methods: {
    changeState (state) {
      this.$emit('change-state', state)
    },
    clearFinished () {
      this.$emit('clear-finished')
    }
  },
}
</script>